<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script type="text/javascript">
      let arr = [60,59,99];

      let result = arr.reduce(function (tmp, item, index){
            alert(tmp + ' ' + item + ' ' + index );
            if(index!=arr.length-1)
            {
                return tmp+item;
            }
            else {
                return (tmp+item)/arr.length;
            }

      });

      alert(result);
    </script>

  </head>
  <body>

  </body>
</html>
